export default async (event: any) => {

  ///已经改成使用useCookie() 不在使用这个api


  //declare function getCookie(event: H3Event, name: string): string | undefined;
  //declare function setCookie(event: H3Event, name: string, value: string, serializeOptions?: CookieSerializeOptions): void;
  //declare function deleteCookie(event: H3Event, name: string, serializeOptions?: CookieSerializeOptions): void;

  const path: string = event.context.params._;
  const body = await readBody(event);
  switch (path) {
    case "set":
      let days = 7;//7天后过期
      let date = new Date();
      date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
      await setCookie(event, body.key, body.value, { expires: date });
      return "Success";
    case "get":
      return await getCookie(event, body.key);
    case "remove":
      await deleteCookie(event, body.key);
      return "removed";
  }

  return "";
};
